<?php

class CommonPage extends Module{

	public function __construct(){
		$this->author = "Tomáš Voslař";
		$this->name = "Obecná stránka";
		$this->presenter = "CommonPage";
		$this->version = "0.1";
		$this->params = "";
	}

	public function getSql(){
			
		dibi::query("CREATE TABLE IF NOT EXISTS " . TABLE_PREFIX . "`page` (
  				`id_page` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  				`id_menu` mediumint(8) unsigned NOT NULL,
  				`content` text NOT NULL,
  				PRIMARY KEY (`id_page`),
  				KEY `fk_id_menu` (`id_menu`)
				) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
				");
		
		dibi::query("ALTER TABLE `" . TABLE_PREFIX . "page`
 				 ADD CONSTRAINT `page_ibfk_1` FOREIGN KEY (`id_menu`) REFERENCES `" . TABLE_PREFIX . "menu` (`id_menu`) ON DELETE CASCADE ON UPDATE CASCADE;");
			
	}
	
	public function getSearch(){

		$search = array("presenter" => "CommonPage");
		
		return $search;
	}
	
	public function getSearchSql(){
		
		return $search = dibi::select("name_seo")->as("id")
					->select("content")->as("searchText")
					->select("name")->as("searchName")
					->from(TABLE_MENU)->as("m")
					->leftJoin(TABLE_PREFIX."page")
					->using("(id_menu)");
	}
	
	public function getSearchData(){
		
		$data = array("cond" => array("content"), "presenter" => "CommonPage", "params" => array("id"));
		
		return $data;
		
	}

}

?>